package cn.chinaflame.pagodas.entity;

import cn.chinaflame.pagodas.schedul.PaOrderFailure;
import cn.chinaflame.pagodas.schedul.PaOrderSchedule;
import cn.chinaflame.pagodas.utils.ScheduleTime;

import java.math.BigDecimal;
import java.util.Objects;
import javax.persistence.*;
/**
 * @author created by lbq
 * @date 2018年1月4日 下午2:31:09
 **/
@Entity
@Table(name = "pa_order", schema = "pagoda", catalog = "")
public class PaOrder {
    private String id;
    private String memberId;
    private String mobile;
    private String openid;
    private BigDecimal money;
    private BigDecimal totalMoney;
    private String orderType;
    private String transType;
    private String payType;
    private String payStatus;
    private String errorMsg;
    private String itemId;
    private String channel;
    private String serialNumber;
    private String ip;
    private String addTime;
    private String payTime;
    private String payFinishTime;
    private String createtime;
    private String updatetime;


    private ScheduleTime time;

    @Id
    @Column(name = "id", nullable = false, length = 20)
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Basic
    @Column(name = "mobile", nullable = true, length = 20)
    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    @Basic
    @Column(name = "order_type", nullable = true, length = 5)
    public String getOrderType() {
        return orderType;
    }

    public void setOrderType(String orderType) {
        this.orderType = orderType;
    }

    @Basic
    @Column(name = "member_id", nullable = true, length = 20)
    public String getMemberId() {
        return memberId;
    }

    public void setMemberId(String memberId) {
        this.memberId = memberId;
    }

    @Basic
    @Column(name = "openid", nullable = true, length = 40)
    public String getOpenid() {
        return openid;
    }

    public void setOpenid(String openid) {
        this.openid = openid;
    }

    @Basic
    @Column(name = "money", nullable = true, precision = 2)
    public BigDecimal getMoney() {
        return money;
    }

    public void setMoney(BigDecimal money) {
        this.money = money;
    }

    @Basic
    @Column(name = "total_money", nullable = true, precision = 2)
    public BigDecimal getTotalMoney() {
        return totalMoney;
    }

    public void setTotalMoney(BigDecimal totalMoney) {
        this.totalMoney = totalMoney;
    }

    @Basic
    @Column(name = "trans_type", nullable = true, length = 10)
    public String getTransType() {
        return transType;
    }

    public void setTransType(String transType) {
        this.transType = transType;
    }

    @Basic
    @Column(name = "pay_type", nullable = true, length = 20)
    public String getPayType() {
        return payType;
    }

    public void setPayType(String payType) {
        this.payType = payType;
    }

    @Basic
    @Column(name = "pay_status", nullable = true, length = 1)
    public String getPayStatus() {
        return payStatus;
    }

    public void setPayStatus(String payStatus) {
        this.payStatus = payStatus;
    }

    @Basic
    @Column(name = "error_msg", nullable = true, length = 100)
    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    @Basic
    @Column(name = "item_id", nullable = true, length = 20)
    public String getItemId() {
        return itemId;
    }

    public void setItemId(String itemId) {
        this.itemId = itemId;
    }

    @Basic
    @Column(name = "channel", nullable = true, length = 10)
    public String getChannel() {
        return channel;
    }

    public void setChannel(String channel) {
        this.channel = channel;
    }

    @Basic
    @Column(name = "serial_number", nullable = true, length = 100)
    public String getSerialNumber() {
        return serialNumber;
    }

    public void setSerialNumber(String serialNumber) {
        this.serialNumber = serialNumber;
    }

    @Basic
    @Column(name = "ip", nullable = true, length = 20)
    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    @Basic
    @Column(name = "add_time", nullable = true)
    public String getAddTime() {
        return addTime;
    }

    public void setAddTime(String addTime) {
        this.addTime = addTime;
    }

    @Basic
    @Column(name = "pay_time", nullable = true)
    public String getPayTime() {
        return payTime;
    }

    public void setPayTime(String payTime) {
        this.payTime = payTime;
    }

    @Basic
    @Column(name = "pay_finish_time", nullable = true)
    public String getPayFinishTime() {
        return payFinishTime;
    }

    public void setPayFinishTime(String payFinishTime) {
        this.payFinishTime = payFinishTime;
    }

    @Basic
    @Column(name = "createtime", nullable = true)
    public String getCreatetime() {
        return createtime;
    }

    public void setCreatetime(String createtime) {
        this.createtime = createtime;
    }

    @Basic
    @Column(name = "updatetime", nullable = true)
    public String getUpdatetime() {
        return updatetime;
    }

    public void setUpdatetime(String updatetime) {
        this.updatetime = updatetime;
    }

    @Transient
    public ScheduleTime getTime() {
        return time;
    }

    public void setTime(ScheduleTime time) {
        this.time = time;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        PaOrder ywOrder = (PaOrder) o;
        return Objects.equals(id, ywOrder.id) &&
                Objects.equals(memberId, ywOrder.memberId) &&
                Objects.equals(money, ywOrder.money) &&
                Objects.equals(transType, ywOrder.transType) &&
                Objects.equals(payType, ywOrder.payType) &&
                Objects.equals(payStatus, ywOrder.payStatus) &&
                Objects.equals(errorMsg, ywOrder.errorMsg) &&
                Objects.equals(itemId, ywOrder.itemId) &&
                Objects.equals(channel, ywOrder.channel) &&
                Objects.equals(serialNumber, ywOrder.serialNumber) &&
                Objects.equals(ip, ywOrder.ip) &&
                Objects.equals(addTime, ywOrder.addTime) &&
                Objects.equals(payTime, ywOrder.payTime) &&
                Objects.equals(payFinishTime, ywOrder.payFinishTime) &&
                Objects.equals(createtime, ywOrder.createtime) &&
                Objects.equals(updatetime, ywOrder.updatetime);
    }

    @Override
    public int hashCode() {

        return Objects.hash(id, memberId, money, transType, payType, payStatus, errorMsg, itemId, channel, serialNumber, ip, addTime, payTime, payFinishTime, createtime, updatetime);
    }
    public PaOrder () {}

    public PaOrder (String id, ScheduleTime scheduleTime, String status) {
        setId(id);
        this.payStatus = status;
        PaOrderSchedule.getInstance().startTask(new PaOrderFailure(this),scheduleTime);
    }
}
